<template>
    <div>
        <h1>最近一次更新时间 {{updateaAt}}</h1>
       <vue-ueditor-wrap v-model="detail" :config="myConfig" ></vue-ueditor-wrap>
       <div  class="add-table-wrapper">
            <el-button type="primary" @click="setAuthenticateRule" class="add-table-wrapper-btn">发布</el-button>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            updateaAt:'',
            showAgreement:false,
            detail:'',
            myConfig: {
                // 编辑器不自动被内容撑高
                autoHeightEnabled: false,
                // 初始容器高度
                initialFrameHeight: 400,
                // 初始容器宽度
                initialFrameWidth: '100%',
                // 上传文件接口（这个地址是我为了方便各位体验文件上传功能搭建的临时接口，请勿在生产环境使用！！！）
                // serverUrl: 'http://35.201.165.105:8000/controller.php',
                serverUrl:'https://wxapp.gdhrma.org.cn/ueditor-php/controller.php',
                // UEditor 资源文件的存放路径，如果你使用的是 vue-cli 生成的项目，通常不需要设置该选项，vue-ueditor-wrap 会自动处理常见的情况，如果需要特殊配置，参考下方的常见问题2
                //UEDITOR_HOME_URL: '/peoples_association_backstage/dist//static/UEditor/'
              toolbars: [
                [
                  'undo', 'redo', '|',
                  'bold', 'italic', 'underline', 'strikethrough',
                  'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor',
                  'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                  'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                  'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                  'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                  'simpleupload', 'insertimage', 'insertvideo', 'music',
                  'horizontal', 'date', 'time',
                  'inserttable'
                ]
              ]
                }
        }
    },
    methods: {
        async getAuthenticateRule(){
            let res=await this.$api.getAuthenticateRule();
            if(res.data.level=='success'){
                if(res.data.data){
                    this.detail=res.data.data.content;
                    this.updateaAt=res.data.data.updated_at
                }
            }else{
                this.$message.error(res.data.message)
            }
        },
        async setAuthenticateRule(){
            let res=await this.$api.setAuthenticateRule({content:this.detail})
            if(res.data.level=='success'){
                this.$message.success(res.data.message);
                this.getAuthenticateRule()
            }else{
                this.$message.error(res.data.message)
            }
        },
    },
    mounted() {
        this.getAuthenticateRule()
    },
}
</script>
<style lang="scss" scoped>
    .add-table-wrapper{
        display: flex;
        justify-content: center;
        padding:30px 0;
    }
</style>
